#include "stdafx.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#endif
/////////////////////////////////////////////////////////////////////////////////////////////////
void calc_udl(tagUMyCalcFormula*pFormula,long numCalc,phistory_data paData,double*dataCalc[10],long decNum,long sec_type,_procReflection procReflection)
{
	long i=0;
	double*pcdClose=dataCalc[6];
	double seedPrice(__price_seed__[decNum]);
	for(i=0;i<numCalc;++i)
		pcdClose[i] = paData[i].ClosePx/seedPrice;

	memcpy(dataCalc[2],pcdClose,numCalc*sizeof(double));
	memcpy(dataCalc[3],pcdClose,numCalc*sizeof(double));
	memcpy(dataCalc[4],pcdClose,numCalc*sizeof(double));
	memcpy(dataCalc[5],pcdClose,numCalc*sizeof(double));

	UMyCalc_MA(dataCalc[2],numCalc,pFormula->infoParam[0].nowValue);
	UMyCalc_MA(dataCalc[3],numCalc,pFormula->infoParam[1].nowValue);
	UMyCalc_MA(dataCalc[4],numCalc,pFormula->infoParam[2].nowValue);
	UMyCalc_MA(dataCalc[5],numCalc,pFormula->infoParam[3].nowValue);

	for(i=0;i<numCalc&&(UMyCalc_invalid(dataCalc[2][i])
		||UMyCalc_invalid(dataCalc[3][i])
		||UMyCalc_invalid(dataCalc[4][i])
		||UMyCalc_invalid(dataCalc[5][i]));++i);
	for(;i<numCalc;++i)
	{
		dataCalc[0][i] = (dataCalc[2][i]+dataCalc[3][i]+
							dataCalc[4][i]+dataCalc[5][i])/4;
	}
	memcpy(dataCalc[1],dataCalc[0],numCalc*sizeof(double));
	UMyCalc_MA(dataCalc[1],numCalc,pFormula->infoParam[4].nowValue);
}
/*
UDL:(MA(CLOSE,N1)+MA(CLOSE,N2)+MA(CLOSE,N3)+MA(CLOSE,N4))/4;
MAUDL:MA(UDL,M);
*/
